import 'package:flutter/material.dart';

import 'about_page.dart';
import 'standards/standards_page.dart';
import 'utils_page.dart';
import 'widgets_page.dart';

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Riki UIkit', style: TextStyle(letterSpacing: 4)),
        centerTitle: true,
      ),
      body: IndexedStack(
        index: _currentIndex,
        children: const <Widget>[
          StandardsPage(),
          WidgetsPage(),
          UtilsPage(),
          AboutPage(),
        ],
      ),
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(icon: Icon(Icons.apps), label: 'Standards', tooltip: 'UI/UE规范'),
          BottomNavigationBarItem(icon: Icon(Icons.api), label: 'Widgets', tooltip: '常用控件'),
          BottomNavigationBarItem(icon: Icon(Icons.all_inclusive_sharp), label: 'Utils', tooltip: '工具类'),
          BottomNavigationBarItem(icon: Icon(Icons.info_outline), label: 'About', tooltip: '关于')
        ],
        currentIndex: _currentIndex,
        onTap: (int index) {
          setState(() {
            _currentIndex = index;
          });
        },
      ),
    );
  }
}
